package com.ruoyi.common.core.constant;

import com.ruoyi.common.core.exception.BaseException;
import com.ruoyi.common.core.exception.domain.ExceptionMessage;

public class CommonException extends BaseException {

    public static ExceptionMessage UNKNOWN_EXCEPTION = new ExceptionMessage(Constants.MODULE_NAME, "unknown_exception", "未知异常");
    public static ExceptionMessage NETWORK_EXCEPTION = new ExceptionMessage(Constants.MODULE_NAME, "network_exception", "连接异常");
    public static ExceptionMessage TIMEOUT_EXCEPTION = new ExceptionMessage(Constants.MODULE_NAME, "timeout_exception", "超时异常");
    //1. 没有服务提供者 2. 服务提供者被禁用
    public static ExceptionMessage SERVICE_EXCEPTION = new ExceptionMessage(Constants.MODULE_NAME, "service_exception", "服务异常").setStatus(503);
    public static ExceptionMessage DATABASE_EXCEPTION = new ExceptionMessage(Constants.MODULE_NAME, "database_exception", "数据库异常");

    public static ExceptionMessage BAD_REQUEST = new ExceptionMessage(Constants.MODULE_NAME, "bad_request", "错误的请求").setStatus(400);


    public CommonException(String code, String defaultMessage) {
        super(Constants.MODULE_NAME, code, null, defaultMessage);
//        System.out.println(code+"--"+defaultMessage);
    }

    public CommonException(ExceptionMessage exceptionMessage) {
        super(exceptionMessage);
    }
}
